//

//  yuanshangyiliao
//
//  Created by icholab on 2021/4/26.
//

#import "YGScienceLowerHeaderView.h"

@interface YGScienceLowerHeaderView ()

@property (nonatomic, strong) UIImageView *headerView;
@property (nonatomic, strong) UIButton *collectBtn;

@end

@implementation YGScienceLowerHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initconstraints];
    }
    return self;
}

-(void)initView{
    [self addSubview:self.headerView];
    [self.headerView addSubview:self.collectBtn];
}

-(void)initconstraints{
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(63.5);
            make.left.right.mas_equalTo(self);
            make.height.mas_equalTo(200.5);
    }];
    
    [self.collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.mas_bottom).offset(15);
            make.right.mas_equalTo(self.mas_right).offset(-10);
            make.height.mas_equalTo(25);
            make.width.mas_equalTo(65);
    }];
}

#pragma event
-(void)clickCollectAction{
    
}

#pragma setter


- (UIImageView *)headerView{
    if (!_headerView) {
        _headerView = [[UIImageView alloc]init];
        
    }
    return _headerView;
}

- (UIButton *)collectBtn{
    if (!_collectBtn) {
        _collectBtn = [[UIButton alloc]init];
        [_collectBtn addTarget:self action:@selector(clickCollectAction) forControlEvents:UIControlEventTouchUpInside];
        _collectBtn.layer.borderWidth = 1;
        _collectBtn.layer.cornerRadius = 8;
        _collectBtn.clipsToBounds = YES;
        
        // 设置颜色空间为rgb，用于生成ColorRef
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        // 新建一个红色的ColorRef，用于设置边框（四个数字分别是 r, g, b, alpha）
        CGColorRef borderColorRef = CGColorCreate(colorSpace,(CGFloat[]){ 255, 255, 255, 1 });
        // 设置边框颜色
        _collectBtn.layer.borderColor = borderColorRef;
        [_collectBtn setTitle:@"+订阅" forState:UIControlStateNormal];
        [_collectBtn setTitle:@"取消订阅" forState:UIControlStateSelected];
        _collectBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_collectBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    return _collectBtn;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end



